package com.lwj.liwanjia.adapter;


import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.MySpBean;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

/**
 * Created by 001 on 2017/9/13.
 */

public class WoDeShangPingAdapter extends SuperBaseAdapter<MySpBean.DataBean> {

    private Context mContext;

    public WoDeShangPingAdapter(Context context, List<MySpBean.DataBean> data) {
        super(context, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, MySpBean.DataBean item, int position) {
        holder.setOnClickListener(R.id.tv_xiajia, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.tv_delete, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.tv_edit, new OnItemChildClickListener());
        Glide.with(mContext).load(item.getCommodityimages()).error(R.mipmap.station).into((ImageView) holder.getView(R.id.iv_sp));
        holder.setText(R.id.tv_name, item.getCommodityName())
                .setText(R.id.tv_jieshao, item.getCommodityInfo())
                .setText(R.id.tv_zhekou_price, "¥" + item.getCommodityVipPrice())
                .setText(R.id.tv_price, "¥" + item.getCommodityPrice());
        TextView tvPrice = holder.getView(R.id.tv_price);
        tvPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        ImageView ivStatus = holder.getView(R.id.iv_status);
        if (item.getIsSell() == 1) {//已上架
            holder.setText(R.id.tv_xiajia, "下架");
            ivStatus.setImageResource(R.mipmap.yishangjia);
        } else if (item.getIsSell() == 0) {//已下架
            holder.setText(R.id.tv_xiajia, "上架");
            ivStatus.setImageResource(R.mipmap.yixiajia);
        }

    }

    @Override
    protected int getItemViewLayoutId(int position, MySpBean.DataBean item) {
        return R.layout.adapter_wo_de_shang_ping;
    }
}
